package com.kh.pajx.sop.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.kh.pajx.sop.base.BaseDaoImpl;
import com.kh.pajx.sop.dao.IGradeInfoDao;
import com.kh.pajx.sop.domain.GradeInfo;

/**
 * 年级信息数据持久化操作实现类
 * @author:	azzcsimp
 * @Createdate:	2014年8月14日 下午3:25:39
 */
@Repository
@SuppressWarnings("unchecked")
public class GradeInfoDaoImpl extends BaseDaoImpl<GradeInfo> implements IGradeInfoDao {

	/**
	 * @see com.kh.pajx.bmp.dao.school.IGradeInfoDao#findGradeInfoList()
	 */
	@Override
	public List<GradeInfo> findGradeInfoList() {
		return getSession().createQuery(//
				"FROM GradeInfo g ORDER BY cast(g.graName as int)")//
				.list();
	}

	/**
	 * @see com.kh.pajx.bmp.dao.school.IGradeInfoDao#findGradeInfoList(int)
	 */
	@Override
	public List<GradeInfo> findGradeInfoList(int statusFlag) {
		return getSession().createQuery(//
				"FROM GradeInfo g WHERE g.graStatusFlag = ? ORDER BY cast(g.graName as int)")//
				.setParameter(0, statusFlag) //
				.list();
	}

	/**
	 * @see com.kh.pajx.bmp.dao.school.IGradeInfoDao#findGradeInfoList(java.lang.String)
	 */
	@Override
	public List<GradeInfo> findGradeInfoList(String sclId) {
		return getSession().createQuery(//
				"FROM GradeInfo g WHERE g.sclId = ? ORDER BY cast(g.graName as int)")//
				.setParameter(0, sclId) //
				.list();
	}
	
	/**
	 * @see com.kh.pajx.bmp.dao.school.IGradeInfoDao#findGradeInfoList(java.lang.String, int)
	 */
	@Override
	public List<GradeInfo> findGradeInfoList(String sclId, int statusFlag) {
		return getSession().createQuery(//
				"FROM GradeInfo g WHERE g.sclId = ? AND g.graStatusFlag = ? ORDER BY cast(g.graName as int)")//
				.setParameter(0, sclId) //
				.setParameter(1, statusFlag) //
				.list();
	}

}
